//练习题：封装一个栈

#include<iostream>
using namespace std;
#include<string.h>
#include<stdlib.h>

class Stack
{
public:
//定义行为
    void init();
    bool isEmpty();
    bool isFull();
    char pop();
    void push(char d);
private:
    //定义数据，private权限控制 类外不得修改
    int top;    //栈指针sp
    char space[1024]; //静态栈空间
};

void Stack::init()
{
    memset(space,0,1024);
    top = 0;
}
bool Stack::isEmpty()
{
    return top == 0;
}
bool Stack::isFull()
{
    return top == 1024;
}
char Stack::pop()
{
    char d = space[--top];
    return d;
}
void Stack::push(char d)
{
    space[top++] = d;
}


int main ()
{
    Stack s;
    s.init();

    for(char d = 'a'; !s.isFull()&& d!='g';d++)
    {
        s.push(d);
    }
    while(!s.isEmpty())
        cout<<s.pop()<<endl;

    return 0;
}